package org.tinygroup.managemenu.action;

import com.alibaba.fastjson.JSON;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;


@Controller()
public class ActionDev {

    @RequestMapping(value = "/{pageId}", method = RequestMethod.GET)
    public String showBankView( @PathVariable String pageId) {
        return pageId;
    }

    @RequestMapping(value = "/{pageId2}/{pageId}", method = RequestMethod.GET)
    public String showBankView1(@PathVariable String pageId2, @PathVariable String pageId) {
        return pageId2 + "/" + pageId;
    }

    @RequestMapping(value = "/{partId1}/{pageId}/{pageId2}", method = RequestMethod.GET)
    public String showBankSubView(@PathVariable String partId1, @PathVariable String pageId,@PathVariable String pageId2) {
        return partId1+"/" + pageId + "/" + pageId2;
    }

    @RequestMapping(value = "/{partId1}/{pageId}/{pageId2}/{pageId3}", method = RequestMethod.GET)
    public String showBankSubView2(@PathVariable String partId1, @PathVariable String pageId,@PathVariable String pageId2,@PathVariable String pageId3) {
        return partId1+"/" + pageId + "/" + pageId2+"/"+pageId3;
    }

    @RequestMapping({"", "/"})
    public String dodo() {
        return "index";
    }

    @RequestMapping("/saveMenu")
    @ResponseBody
    public void saveTree(HttpServletRequest request, HttpSession session) {
        session.setAttribute("menuList", JSON.parse(request.getParameter("data")));
    }


}
